package com.qingke.Qiximybatis.business;

import org.apache.ibatis.session.SqlSession;
import com.qingke.Qiximybatis.QixiApp;
import com.qingke.Qiximybatis.QixiConsole;
import com.qingke.Qiximybatis.QixiDao;
import com.qingke.Qiximybatis.command.UserCommand;
import com.qingke.Qiximybatis.mapper.InterestMapper;
import com.qingke.Qiximybatis.sqlclass.Interest;
import com.qingke.Qiximybatis.sqlclass.MyUser;

public class Interest5 extends UserCommand{
	public Interest5(MyUser user) {
		super(user);
	}
	
	@Override
	public void executeUserCommand() {
		System.out.println("欢迎来到兴趣信息修改界面：");
		SqlSession session = QixiDao.mybatisSession();
		int id = QixiApp.getInstance().getUser().getId();
		Interest inter = new Interest();
		
		String name = QixiConsole.askUserInput("请输入要修改的name:");
		String level = QixiConsole.askUserInput("请输入要修改的level：");
		int lel = Integer.parseInt(level);
		
		inter.setUserId(id);
		inter.setName(name);
		inter.setLevel(lel);
		InterestMapper interM = session.getMapper(InterestMapper.class);
		interM.updateInterset(inter);
		session.commit();
		session.close();
		System.out.println("修改内容成功！");
	}
}
